Skip to content

luci-mod-system, luci-mod-status: permit sysupgrade --create-backup and legacy iptables-save - #8947

Open
JuliusBairaktaris wants to merge 2 commits into
openwrt:masterfrom
JuliusBairaktaris:backup-create-acl
Open

luci-mod-system, luci-mod-status: permit sysupgrade --create-backup and legacy iptables-save#8947
JuliusBairaktaris wants to merge 2 commits into
openwrt:masterfrom
JuliusBairaktaris:backup-create-acl

Conversation

@JuliusBairaktaris

@JuliusBairaktaris JuliusBairaktaris commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

The firewall status page runs the legacy iptables-save pair whenever those binaries
exist, and only the non-legacy pair is in the session ACL. The .catch() covers a
failed stat(), so a device that carries the legacy binaries never falls back to the
non-legacy command.

modules/luci-mod-status/htdocs/luci-static/resources/view/status/nftables.js, load():

        fs.stat('/usr/sbin/iptables-legacy-save').then(function() {
                return L.resolveDefault(fs.exec_direct('/usr/sbin/iptables-legacy-save'), '');
        }).catch(function() {
                return L.resolveDefault(fs.exec_direct('/usr/sbin/iptables-save'), '');
        }),

cgi-io matches the requested command against the caller's session ACL and refuses the
exec. handleCgiIoReply() in luci-base/htdocs/luci-static/resources/fs.js turns the
403 into a PermissionError and L.resolveDefault(..., '') turns that into an empty
string, so the legacy tables come back empty. The luci-mod-status half is a fix against
current master on its own.

main.c, main_exec() (cgi-io master):

        /* If there was no ACL match, check for a match on the executable */
        if (!allowed && !session_access(fields[1], "file", exe, "exec")) {
                free(args);
                return failure(403, 0, "Access to command denied by ACL");

The luci-mod-system half only takes effect once openwrt/cgi-io#6 lands. On cgi-io
master the archive is created by cgi-io itself, gated on the cgi-io backup scope and
not on a file exec grant, so the new entry is unused today.

main.c, main_backup() (cgi-io master):

        if (!fields[1] || !session_access(fields[1], "cgi-io", "backup", "read"))
                return failure(403, 0, "Backup permission denied");
        ...
        execl("/sbin/sysupgrade", "/sbin/sysupgrade",
              "--create-backup", "-", NULL);

openwrt/cgi-io#6 moves that exec to rpcd's file method so it keeps working when uhttpd
runs as a non-root user (openwrt/openwrt#24740), and openwrt/rpcd#40 returns the
child's stdout as a file descriptor so the archive is streamed. rpcd matches on the
command line, so the grant names the exact string, the same form as the
/sbin/sysupgrade --list-backup entry already in that ACL. Both PRs are still open.

Depends on openwrt/cgi-io#6 and openwrt/rpcd#40.

I used AI to help me write the change. The empty-table behaviour is read from the
code chain above; I have not reproduced it on a device. Should the luci-mod-status
commit go in on its own now, since it fixes current master, and the
luci-mod-system one wait for cgi-io#6?

Copilot AI lite review requested due to automatic review settings August 15, 2026 07:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@JuliusBairaktaris

Copy link
Copy Markdown
Contributor Author

@jow- — review ping.

One-line ACL grant permitting exactly /sbin/sysupgrade --create-backup -, in the same luci-mod-system-flash read section as the existing --list-backup grant. rpcd matches the bare executable first and then executable + " " + each param, so this is an exact match with no glob metacharacters.

Needed by openwrt/cgi-io#6, which is in turn needed by openwrt/openwrt#24558.

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 new commits. Both commit messages match their diffs, both files stay valid JSON, and the ACL strings are in the correct read sections. Two inline notes — the main one is a question about whether rpcd's file.exec can actually carry a backup tarball, since it is fully buffered and returns stdout as a NUL-terminated string.


Generated by Claude Code

openwrt/cgi-io#6 moves archive creation to rpcd's file exec method so
that it keeps working when uhttpd runs as a non-root user, and
openwrt/rpcd#40 returns the child's stdout as a file descriptor so the
archive is streamed rather than buffered into the ubus reply. rpcd
matches the requested command against the caller's session ACL, so the
grant names the exact command line.

Depends on openwrt/cgi-io#6 and openwrt/rpcd#40.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
Only the non-legacy iptables-save pair is in the session ACL, but the
firewall status page runs the legacy pair when those binaries exist.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
@JuliusBairaktaris JuliusBairaktaris changed the title luci-mod-system: permit sysupgrade --create-backup over rpcd luci-mod-system, luci-mod-status: permit sysupgrade --create-backup and legacy iptables-save Sep 7, 2026

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 new commits; no new issues found.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants